package cn.itcast.clone;

/**
 * @Author : 叶荻风
 * @create : 2024/8/5 17:05
 */

public class Person implements Cloneable{
    private Address address;
    @Override
    public Person clone() {
        try {
            Person person = (Person) super.clone();
            //深拷贝，每一个类成员变量都拿去拷贝，再赋值
            //person.setAddress(person.getAddress().clone());
            return person;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Person(Address address) {
        this.address = address;
    }
}
